﻿using PrinterMonitorSvc.Ext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrinterMonitorSvc.Common
{
    public static class LogHelper
    {
        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="msg"></param>
        public static void LogError(string msg)
        {
            Log(msg, DateTime.Now.ToString("yyyy-MM-dd") + "-error.txt");
        }

        /// <summary>
        /// 记录性能日志
        /// </summary>
        /// <param name="msg"></param>
        public static void LogPerformance(string msg)
        {
            Log(msg, DateTime.Now.ToString("yyyy-MM-dd") + "-info.txt");
        }

        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="msg"></param>
        private static void Log(string msg, string filename)
        {
            FileHelper.SaveFileByAppend(DateTime.Now.ToDateTimeString() + "：" + msg + "\r\n", ("log\\" + filename).ToPhysicalPath());
        }
    }
}
